<template>
	<view class="shengqingjiebang">
		<wanl-empty text="没有更多数据了" v-if=" list.length === 0" />

		<view class="u-p-t-32" v-for="(goods, index) in list" :key="index">
			<!-- 商品选择 -->

			<view class="forbox wanl-cart-goods u-flex-col padding-bj" style="align-items: stretch;">
				<view class="flex_ac" @tap="$wanlshop.to('/pages/craftsman/company/homepage?id=' + goods.user_id)">
					<image style="width: 132rpx;height: 132rpx;" class="br100" :src="$wanlshop.oss(goods.avatar)"
						mode=""></image>
					<view class="flex1 ml24 minwidth overflow_1">
						<view class="f32 overflow_1 fb">
							{{goods.name}}
							<u-tag class="ml12" :text="goods.work_time + '年'" size="mini" mode="dark" type="warning" />
						</view>
						<view class="mt8 flex overflow_1">
							<scroll-view scroll-x="true">
								<u-tag class="mr12" :text="i" size="mini" mode="light"
									v-for="(i,k) in goods.work_type_text" :key="k" shape="circle" />
							</scroll-view>
						</view>

					</view>
					<view class="">
						<!-- <u-button size="mini" class="ml24" type="info" plain=""
							@click='applyfor(goods, index,-1)'>拒绝</u-button> -->
						<u-button size="mini" class="ml24" type="primary"
							@click='applyfor(goods, index,1)'>同意</u-button>
					</view>

				</view>

			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.waitUnbind()
		},
		methods: {
			applyfor(item, key, type) {
				let _this = this

				let url, content
				if (type == 1) {
					url = '/worker/user_join/agreeUnbind'
					content = `确定同意${item.name}解绑吗？`
				}


				uni.showModal({
					title: `提示`,
					content: content,
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							_this.$api.post({
								url: url,
								data: {
									user_id: item.user_id,
								},
							}).then(res1 => {
								_this.list.splice(key, 1)
								uni.showToast({
									icon: 'none',
									title: '操作成功'
								})
							})
						} else if (res.cancel) {}
					}
				});
			},

			waitUnbind() {
				this.$api.get({
					url: '/worker/user_join/waitUnbind',
					data: {
						limit: 999,
						page: 1,
						type: 1
					},

				}).then(res => {
					console.log(res);
					this.list = res.data
				})
			},
		},
	}
</script>

<style>
	.forbox {
		background: #fff;
	}
</style>